package com.micro.ai.template.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * 工作流定义实体
 *
 * @author micro-ai
 * @since 0.0.1
 */
@Data
@TableName(value = "workflow_definitions", autoResultMap = true)
@Schema(description = "工作流定义")
public class WorkflowDefinition {

    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @Schema(description = "主键ID")
    private String id;

    @TableField("workflow_id")
    @Schema(description = "工作流ID")
    private String workflowId;

    @TableField("workflow_name")
    @Schema(description = "工作流名称")
    private String workflowName;

    @TableField("description")
    @Schema(description = "描述")
    private String description;

    @TableField(value = "definition", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "工作流定义")
    private Map<String, Object> definition;

    @TableField(value = "input_schema", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "输入Schema")
    private Map<String, Object> inputSchema;

    @TableField(value = "output_schema", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "输出Schema")
    private Map<String, Object> outputSchema;

    @TableField("enabled")
    @Schema(description = "是否启用")
    private Boolean enabled;

    @TableField("version")
    @Schema(description = "版本号")
    private String version;

    @TableField(value = "tags", typeHandler = JacksonTypeHandler.class)
    @Schema(description = "标签列表")
    private List<String> tags;

    // ============================================================================
    // ✅ 多租户和用户关联
    // ============================================================================

    @TableField("tenant_id")
    @Schema(description = "所属租户ID", example = "tenant_001")
    private String tenantId;

    @TableField("created_by")
    @Schema(description = "创建者用户ID", example = "usr_001")
    private String createdBy;

    @TableField("created_at")
    @Schema(description = "创建时间")
    private LocalDateTime createdAt;

    @TableField("updated_at")
    @Schema(description = "更新时间")
    private LocalDateTime updatedAt;
}

